package com.charge.util;

/**
 * Description :
 * Author : 91658
 * Date : 2018/6/7 10:52
 **/
public class Page {

    //默认页面记录数
    public final static int DEFAULT_PAGE_SIZE = 10;
    //当前所在页码
    private Integer pageNo;
    //页面大小
    private Integer pageSize;
    //总记录数
    private Integer total;
    // 开始行
    private Integer beginRow;
    // 结束行
    private Integer endRow;

    public Page(Integer pageNo, Integer pageSize, Integer total) {
        this.pageNo = pageNo > 0 ? pageNo : 1;

        this.total = total;

        if(pageSize != null && pageSize > 0) {
            this.pageSize = pageSize;
        } else {
            this.pageSize = DEFAULT_PAGE_SIZE;
        }

        this.beginRow = (pageNo - 1) * pageSize + 1;

        this.endRow = pageNo * pageSize;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getBeginRow() {
        return beginRow;
    }

    public void setBeginRow(Integer beginRow) {
        this.beginRow = beginRow;
    }

    public Integer getEndRow() {
        return endRow;
    }

    public void setEndRow(Integer endRow) {
        this.endRow = endRow;
    }
}
